package com.techstar.api.service.hinge_situation;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;

import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.type.TypeReference;
import com.techstar.api.pojo.hinge_situation.HingeSituationEvent;
import com.techstar.api.repos.hinge_situation.HingeSituationEventRepos;
import com.techstar.api.service.ConfigProperties;
import com.techstar.api.service.ParentOfListService;
import com.techstar.common.pojo.InterfaceType;
/**
 * 
 * @author EinIce
 * @description 各枢纽实时突发事件
 * @date 2021年9月9日
 */
@Service
public class HingeSituationEventService extends ParentOfListService<HingeSituationEvent> {
	
	@Autowired
	private HingeSituationEventRepos beanRepos;
	
	@Autowired
	private ConfigProperties configProperties; // 配置文件注入
	
	public void query() {
		try {
		gateWayApiProperties = configProperties.romaHingeSituationApiProperties();
		trafficApiProperties = configProperties.hseApiProperties();
		String currentTime = URLEncoder.encode(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"), "UTF-8").replaceAll("\\+", "%20");
		trafficApiProperties.param = String.format("current_date=%s" , currentTime);
		interfaceType = InterfaceType.HINGE_SITUATION_EVENT;
		super.beanRepos = beanRepos;
		sendHttp(new TypeReference<List<HingeSituationEvent>>() {}, new String[] {"data"});
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
